/***********************************************
 This file is part of redia-bapps-main-ios.
 
 Copyright (c) 2015 Redia A/S
 
 Redia-bapps-main-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-bapps-main-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-bapps-main-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

//
//  BAFeaturedNewsPageViewController.m
//  redia-bapps-ios
//
//  Created by Nikolaj Tørring on 24/10/13.
//  Copyright (c) 2013 redia. All rights reserved.
//

#import "BAFeaturedNewsPageViewController.h"
#import "BAFeaturedNewsButton.h"
#import "BANewsViewController.h"

@interface BAFeaturedNewsPageViewController ()

@end

@implementation BAFeaturedNewsPageViewController

-(void)setNewsElements:(NSArray *)newsElements{
    if (_newsElements != newsElements) {
        _newsElements = newsElements;
        
        NSMutableArray* featureButtons = [NSMutableArray new];
        for (BANews* news in self.newsElements) {
            BAFeaturedNewsButton* currentButton = [BAFeaturedNewsButton new];
            [currentButton setNews:news];
            [featureButtons addObject:currentButton];
        }
        self.featureButtons = featureButtons;
        [self finishSetupView];
    }
}

- (void)featureButtonClicked:(id)sender {
    BAFeaturedNewsButton* newsButton = sender;
    if (self.navigationController != nil && newsButton.news != nil) {
        BANewsViewController* newsViewController = [BANewsViewController newsViewControlerWithNews:newsButton.news];
        [self.navigationController pushViewController:newsViewController animated:YES];
    }
}

@end
